/**************************************************************************************
*
*	Copyright (C) 2010 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	RendererDevice.h
*
*	Description -	
*
*	Comments	-	We'll be using DX9 for this rendererDevice. We need to abstract 
*						this in the future.
*
*	Modification History:
*			Name			   Date					Description
*			CodeSushi	-	10/15/2010	-	Creation of this file
**************************************************************************************/

#ifndef _PSX_RENDERER_DEVICE_H_
#define _PSX_RENDERER_DEVICE_H_

#include "PulseSTD.h"
#include "Singleton.h"
#include "EventManager.h"
#include "GraphicsTypes.h"

#include <D3D9.h>

namespace Pulse
{

	class RendererDevice
	{
	public:

		RendererDevice( IDirect3D9 *pD3D, D3DPRESENT_PARAMETERS *pParams, ::HWND _hwnd = PSX_NULL, 
			EProcessingType::Type type = EProcessingType::PURE_HARDWARE );

		virtual ~RendererDevice( void );

		// Performs actions on device creation.
		virtual void OnDeviceCreate( void ) { }

		// Performs actions when rendering device is lost.
		virtual void OnDeviceLost( void );

		// Performs actions on device destruction.
		virtual void OnDeviceDestroy( void ) { }

		/********************************************************************************
		*	Function Name :	TestCapabilities
		*	Description	  :	Use this function to check for graphics card capabilities.
		*	In			  :	caps - caps the setting/capability/whatever you want to test to ensure
		*							that user's graphics adapter will handle it properly.
		*	Out			  :	pParam - The result the function produces such as version of shaders
		*	Return		  :	BOOL - True if succesful.
		*	Example		  : 
		********************************************************************************/
		virtual BOOL TestCapabilities( EGraphicsCaps::Type caps, void *pParam );

		//virtual void HandleEvent( const 

		// Device initialization
		virtual EErrorCode::Type Initialize( void );
		
		// Device cleanup
		virtual void Cleanup( void );

		virtual void Reset( void );
		virtual void Reset( D3DPRESENT_PARAMETERS *pParams );

		virtual void * GetDevice( void ) { return m_pD3DDev; }

		virtual IDirect3D9 * GetD3D( void ) { return m_pD3D; }

		virtual void BeginRender( void );

		virtual void EndRender( void );

		const BOOL IsDeviceLost( void ) const { return m_bIsLost; }

	private:

		// TOE
		RendererDevice( void );
		RendererDevice( const RendererDevice &device );
		RendererDevice & operator = ( const RendererDevice &rhs );

	protected:

		mutable BOOL			m_bIsLost;
		EProcessingType::Type	m_processingType;

		//
		IDirect3DDevice9		*m_pD3DDev;
		IDirect3D9				*m_pD3D;
		D3DPRESENT_PARAMETERS	m_params;
		D3DCAPS9				m_devCaps;
		::HWND					m_hWnd;

	};

}

#endif /* _PSX_RENDERER_DEVICE_H_ */